import java.util.Arrays;
import java.util.Scanner;

abstract class Shape{
	protected final double PI=3.14;
	public abstract double getPerimeter();
	public abstract double getArea();
	public static double sumPerimeter(Shape[] shapes){
		double sumPerimeter=0;
		for(Shape shape:shapes){
			sumPerimeter+=shape.getPerimeter(); 
		}
	   	return sumPerimeter;
	}
	public static double sumAllArea(Shape[] shapes){
		double sumAllArea=0;
		for(Shape shape:shapes){
			sumAllArea+=shape.getArea(); 
		}
		return sumAllArea;
    }
}
class Rectangle extends Shape {
	private int width;
	private int length;
	public Rectangle(int width,int length){
		this.width=width;
		this.length=length;
	}
	public int getWidth() {
		return width;
	}
	public void setWidth(int width) {
		this.width = width;
	}
	public int getLength() {
		return length;
	}
	public void setLength(int length) {
		this.length = length;
	}
	@Override
	public double getPerimeter() {
		// TODO Auto-generated method stub
		return 2*(this.length+this.width);
	}
	@Override
	public double getArea() {
		// TODO Auto-generated method stub
		return this.length*this.width;
	}
	@Override
	public String toString() {
		return "Rectangle [width=" + width + ", length=" + length + "]";
	}
}
class Circle extends Shape{
	private int radius;
	public Circle(int radius){
		this.radius=radius;
	}
	public int getRadius() {
		return radius;
	}
	public void setRadius(int radius) {
		this.radius = radius;
	}
	@Override
	public double getPerimeter() {
		// TODO Auto-generated method stub
		return 2*super.PI*radius;
	}
	@Override
	public double getArea() {
		// TODO Auto-generated method stub
		return super.PI*radius*radius;
	}
	@Override
	public String toString() {
		return "Circle [radius=" + radius + "]";
	}
}
public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		Shape[] shapes=new Shape[n];
		for (int i = 0; i <n ; ++i) {
			String str=sc.next();
			if (str.equals("rect")) {
				Rectangle rect=new Rectangle(sc.nextInt(),sc.nextInt());
				shapes[i]=rect;
				continue;
			}
			if (str.equals("cir")) {
				Circle cir=new Circle(sc.nextInt());
				shapes[i]=cir;
				continue;
			}
		}
		System.out.println(Shape.sumPerimeter(shapes));
		System.out.println(Shape.sumAllArea(shapes));
		System.out.println(Arrays.deepToString(shapes));
		for (Shape shape : shapes) {
			System.out.println(shape.getClass()+","+shape.getClass().getSuperclass());
		}
		sc.close();
	}
}
